home *** CD-ROM | disk | FTP | other *** search
- public class JMxTimer implements Runnable {
- public static final int MX_TMTHD_IDLE = 0;
- public static final int MX_TMTHD_START = 1;
- public static final int MX_TMTHD_STARTED = 2;
- public static final int MX_TMTHD_STOP = 3;
- public static final int MX_TMTHD_KILL = 4;
- public static final int MX_TMTHD_KILLED = 5;
- public JMxTimeable m_Owner;
- public Thread m_TimerThread;
- private long m_Interval;
- public int m_State;
-
- public synchronized void Kill() {
- if (this.m_State != 4) {
- this.m_State = 4;
- this.notifyAll();
- }
-
- }
-
- public synchronized void Stop() {
- switch (this.m_State) {
- case 1:
- case 2:
- this.m_State = 3;
- this.notifyAll();
- return;
- default:
- }
- }
-
- public JMxTimer(JMxTimeable var1) {
- this.m_Owner = var1;
- this.m_TimerThread = new Thread(this);
- this.m_TimerThread.start();
- }
-
- public void run() {
- synchronized(this){}
-
- try {
- boolean var1 = false;
-
- while(true) {
- var1 = false;
- switch (this.m_State) {
- case 0:
- var1 = true;
- break;
- case 1:
- this.m_State = 2;
-
- try {
- this.wait(this.m_Interval);
- } catch (InterruptedException var10) {
- }
- break;
- case 2:
- this.m_Owner.tick(this);
- this.m_State = 0;
- var1 = true;
- break;
- case 3:
- this.m_State = 0;
- var1 = true;
- break;
- case 4:
- this.m_State = 5;
- return;
- }
-
- if (var1) {
- try {
- this.wait();
- } catch (InterruptedException var9) {
- ((Throwable)var9).printStackTrace();
- }
- }
- }
- } catch (Throwable var11) {
- throw var11;
- }
- }
-
- public synchronized boolean Start(long var1) {
- switch (this.m_State) {
- case 0:
- case 3:
- this.m_Interval = var1;
- this.m_State = 1;
- this.notifyAll();
- return true;
- case 1:
- this.notifyAll();
- case 2:
- case 4:
- default:
- return false;
- }
- }
- }
-